<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>errorreporter_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_debug_errorreporter_test.js.html">errorreporter_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2009 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.debug.ErrorReporterTest&#39;);
<a name="line16"></a>goog.setTestOnly(&#39;goog.debug.ErrorReporterTest&#39;);
<a name="line17"></a>
<a name="line18"></a>goog.require(&#39;goog.debug.ErrorReporter&#39;);
<a name="line19"></a>goog.require(&#39;goog.events&#39;);
<a name="line20"></a>goog.require(&#39;goog.functions&#39;);
<a name="line21"></a>goog.require(&#39;goog.testing.PropertyReplacer&#39;);
<a name="line22"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line23"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line24"></a>
<a name="line25"></a>MockXhrIo = function() {};
<a name="line26"></a>
<a name="line27"></a>MockXhrIo.prototype.onReadyStateChangeEntryPoint_ = function() {};
<a name="line28"></a>
<a name="line29"></a>MockXhrIo.protectEntryPoints = function() {};
<a name="line30"></a>
<a name="line31"></a>MockXhrIo.lastUrl = null;
<a name="line32"></a>
<a name="line33"></a>MockXhrIo.send = function(url, opt_callback, opt_method, opt_content,
<a name="line34"></a>    opt_headers, opt_timeInterval) {
<a name="line35"></a>  MockXhrIo.lastUrl = url;
<a name="line36"></a>  MockXhrIo.lastContent = opt_content;
<a name="line37"></a>  MockXhrIo.lastHeaders = opt_headers;
<a name="line38"></a>};
<a name="line39"></a>
<a name="line40"></a>var errorReporter;
<a name="line41"></a>var originalSetTimeout = window.setTimeout;
<a name="line42"></a>var stubs = new goog.testing.PropertyReplacer();
<a name="line43"></a>var url = &#39;http://www.your.tst/more/bogus.js&#39;;
<a name="line44"></a>var encodedUrl = &#39;http%3A%2F%2Fwww.your.tst%2Fmore%2Fbogus.js&#39;;
<a name="line45"></a>
<a name="line46"></a>function setUp() {
<a name="line47"></a>  stubs.set(goog.net, &#39;XhrIo&#39;, MockXhrIo);
<a name="line48"></a>  goog.debug.ErrorReporter.ALLOW_AUTO_PROTECT = true;
<a name="line49"></a>}
<a name="line50"></a>
<a name="line51"></a>function tearDown() {
<a name="line52"></a>  goog.dispose(errorReporter);
<a name="line53"></a>  stubs.reset();
<a name="line54"></a>  MockXhrIo.lastUrl = null;
<a name="line55"></a>}
<a name="line56"></a>
<a name="line57"></a>function throwAnErrorWith(script, line, message, opt_stack) {
<a name="line58"></a>  var error = {
<a name="line59"></a>    message: message,
<a name="line60"></a>    fileName: script,
<a name="line61"></a>    lineNumber: line};
<a name="line62"></a>  if (opt_stack) {
<a name="line63"></a>    error[&#39;stack&#39;] = opt_stack;
<a name="line64"></a>  }
<a name="line65"></a>
<a name="line66"></a>  throw error;
<a name="line67"></a>}
<a name="line68"></a>
<a name="line69"></a>function testsendErrorReport() {
<a name="line70"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line71"></a>  errorReporter.sendErrorReport(
<a name="line72"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;);
<a name="line73"></a>
<a name="line74"></a>  assertEquals(&#39;/log?script=filename.js&amp;error=message&amp;line=123&#39;,
<a name="line75"></a>      MockXhrIo.lastUrl);
<a name="line76"></a>  assertEquals(&#39;trace=trace&#39;, MockXhrIo.lastContent);
<a name="line77"></a>}
<a name="line78"></a>
<a name="line79"></a>function testsendErrorReportWithCustomSender() {
<a name="line80"></a>  var uri = null;
<a name="line81"></a>  var method = null;
<a name="line82"></a>  var content = null;
<a name="line83"></a>  var headers = null;
<a name="line84"></a>  function mockXhrSender(uriIn, methodIn, contentIn, headersIn) {
<a name="line85"></a>    uri = uriIn;
<a name="line86"></a>    method = methodIn;
<a name="line87"></a>    content = contentIn;
<a name="line88"></a>    headers = headersIn;
<a name="line89"></a>  }
<a name="line90"></a>
<a name="line91"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line92"></a>  errorReporter.setXhrSender(mockXhrSender);
<a name="line93"></a>  errorReporter.sendErrorReport(&#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;);
<a name="line94"></a>
<a name="line95"></a>  assertEquals(&#39;/log?script=filename.js&amp;error=message&amp;line=123&#39;, uri);
<a name="line96"></a>  assertEquals(&#39;POST&#39;, method);
<a name="line97"></a>  assertEquals(&#39;trace=trace&#39;, content);
<a name="line98"></a>  assertUndefined(headers);
<a name="line99"></a>}
<a name="line100"></a>
<a name="line101"></a>function testsendErrorReport_noTrace() {
<a name="line102"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line103"></a>  errorReporter.sendErrorReport(
<a name="line104"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123);
<a name="line105"></a>
<a name="line106"></a>  assertEquals(&#39;/log?script=filename.js&amp;error=message&amp;line=123&#39;,
<a name="line107"></a>      MockXhrIo.lastUrl);
<a name="line108"></a>  assertEquals(&#39;&#39;, MockXhrIo.lastContent);
<a name="line109"></a>}
<a name="line110"></a>
<a name="line111"></a>function test_nonInternetExplorerSendErrorReport() {
<a name="line112"></a>  stubs.set(goog.userAgent, &#39;IE&#39;, false);
<a name="line113"></a>  stubs.set(goog.global, &#39;setTimeout&#39;,
<a name="line114"></a>      function(fcn, time) {
<a name="line115"></a>        fcn.call();
<a name="line116"></a>      });
<a name="line117"></a>
<a name="line118"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line119"></a>
<a name="line120"></a>  var errorFunction = goog.partial(throwAnErrorWith, url, 5, &#39;Hello :)&#39;);
<a name="line121"></a>
<a name="line122"></a>  try {
<a name="line123"></a>    goog.global.setTimeout(errorFunction, 0);
<a name="line124"></a>  } catch (e) {
<a name="line125"></a>    // Expected. The error is rethrown after sending.
<a name="line126"></a>  }
<a name="line127"></a>
<a name="line128"></a>  assertEquals(
<a name="line129"></a>      &#39;/errorreporter?script=&#39; + encodedUrl + &#39;&amp;error=Hello%20%3A)&amp;line=5&#39;,
<a name="line130"></a>      MockXhrIo.lastUrl);
<a name="line131"></a>  assertEquals(&#39;trace=Not%20available&#39;, MockXhrIo.lastContent);
<a name="line132"></a>}
<a name="line133"></a>
<a name="line134"></a>function test_internetExplorerSendErrorReport() {
<a name="line135"></a>  stubs.set(goog.userAgent, &#39;IE&#39;, true);
<a name="line136"></a>  stubs.set(goog.userAgent, &#39;isVersionOrHigher&#39;, goog.functions.FALSE);
<a name="line137"></a>
<a name="line138"></a>  // Remove test runner&#39;s onerror handler so the test doesn&#39;t fail.
<a name="line139"></a>  stubs.set(goog.global, &#39;onerror&#39;, null);
<a name="line140"></a>
<a name="line141"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line142"></a>  goog.global.onerror(&#39;Goodbye :(&#39;, url, 22);
<a name="line143"></a>  assertEquals(
<a name="line144"></a>      &#39;/errorreporter?script=&#39; + encodedUrl + &#39;&amp;error=Goodbye%20%3A(&amp;line=22&#39;,
<a name="line145"></a>      MockXhrIo.lastUrl);
<a name="line146"></a>  assertEquals(&#39;trace=Not%20available&#39;, MockXhrIo.lastContent);
<a name="line147"></a>}
<a name="line148"></a>
<a name="line149"></a>function test_setLoggingHeaders() {
<a name="line150"></a>  stubs.set(goog.userAgent, &#39;IE&#39;, true);
<a name="line151"></a>  stubs.set(goog.userAgent, &#39;isVersionOrHigher&#39;, goog.functions.FALSE);
<a name="line152"></a>  // Remove test runner&#39;s onerror handler so the test doesn&#39;t fail.
<a name="line153"></a>  stubs.set(goog.global, &#39;onerror&#39;, null);
<a name="line154"></a>
<a name="line155"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line156"></a>  errorReporter.setLoggingHeaders(&#39;header!&#39;);
<a name="line157"></a>  goog.global.onerror(&#39;Goodbye :(&#39;, &#39;http://www.your.tst/more/bogus.js&#39;, 22);
<a name="line158"></a>  assertEquals(&#39;header!&#39;, MockXhrIo.lastHeaders);
<a name="line159"></a>}
<a name="line160"></a>
<a name="line161"></a>function test_nonInternetExplorerSendErrorReportWithTrace() {
<a name="line162"></a>  stubs.set(goog.userAgent, &#39;IE&#39;, false);
<a name="line163"></a>  stubs.set(goog.global, &#39;setTimeout&#39;,
<a name="line164"></a>      function(fcn, time) {
<a name="line165"></a>        fcn.call();
<a name="line166"></a>      });
<a name="line167"></a>
<a name="line168"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line169"></a>
<a name="line170"></a>  var trace =
<a name="line171"></a>      &#39;Error(\&quot;Something Wrong\&quot;)@:0\n&#39; +
<a name="line172"></a>      &#39;$MF$E$Nx$([object Object])@http://a.b.c:83/a/f.js:901\n&#39; +
<a name="line173"></a>      &#39;([object Object])@http://a.b.c:813/a/f.js:37&#39;;
<a name="line174"></a>
<a name="line175"></a>
<a name="line176"></a>  var errorFunction = goog.partial(throwAnErrorWith, url, 5, &#39;Hello :)&#39;,
<a name="line177"></a>      trace);
<a name="line178"></a>
<a name="line179"></a>  try {
<a name="line180"></a>    goog.global.setTimeout(errorFunction, 0);
<a name="line181"></a>  } catch (e) {
<a name="line182"></a>    // Expected. The error is rethrown after sending.
<a name="line183"></a>  }
<a name="line184"></a>
<a name="line185"></a>  assertEquals(
<a name="line186"></a>      &#39;/errorreporter?script=&#39; + encodedUrl + &#39;&amp;error=Hello%20%3A)&amp;line=5&#39;,
<a name="line187"></a>      MockXhrIo.lastUrl);
<a name="line188"></a>  assertEquals(&#39;trace=&#39; +
<a name="line189"></a>      &#39;Error(%22Something%20Wrong%22)%40%3A0%0A&#39; +
<a name="line190"></a>      &#39;%24MF%24E%24Nx%24(%5Bobject%20Object%5D)%40&#39; +
<a name="line191"></a>      &#39;http%3A%2F%2Fa.b.c%3A83%2Fa%2Ff.js%3A901%0A&#39; +
<a name="line192"></a>      &#39;(%5Bobject%20Object%5D)%40http%3A%2F%2Fa.b.c%3A813%2Fa%2Ff.js%3A37&#39;,
<a name="line193"></a>      MockXhrIo.lastContent);
<a name="line194"></a>}
<a name="line195"></a>
<a name="line196"></a>function testProtectAdditionalEntryPoint_nonIE() {
<a name="line197"></a>  stubs.set(goog.userAgent, &#39;IE&#39;, false);
<a name="line198"></a>
<a name="line199"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line200"></a>  var fn = function() {};
<a name="line201"></a>  var protectedFn = errorReporter.protectAdditionalEntryPoint(fn);
<a name="line202"></a>  assertNotNull(protectedFn);
<a name="line203"></a>  assertNotEquals(fn, protectedFn);
<a name="line204"></a>}
<a name="line205"></a>
<a name="line206"></a>function testProtectAdditionalEntryPoint_IE() {
<a name="line207"></a>  stubs.set(goog.userAgent, &#39;IE&#39;, true);
<a name="line208"></a>  stubs.set(goog.userAgent, &#39;isVersionOrHigher&#39;, goog.functions.FALSE);
<a name="line209"></a>
<a name="line210"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line211"></a>  var fn = function() {};
<a name="line212"></a>  var protectedFn = errorReporter.protectAdditionalEntryPoint(fn);
<a name="line213"></a>  assertNull(protectedFn);
<a name="line214"></a>}
<a name="line215"></a>
<a name="line216"></a>function testHandleException_dispatchesEvent() {
<a name="line217"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line218"></a>  var loggedErrors = 0;
<a name="line219"></a>  goog.events.listen(errorReporter,
<a name="line220"></a>      goog.debug.ErrorReporter.ExceptionEvent.TYPE,
<a name="line221"></a>      function(event) {
<a name="line222"></a>        assertNotNullNorUndefined(event.error);
<a name="line223"></a>        loggedErrors++;
<a name="line224"></a>      });
<a name="line225"></a>  errorReporter.handleException(new Error());
<a name="line226"></a>  errorReporter.handleException(new Error());
<a name="line227"></a>  assertEquals(&#39;Expected 2 errors. &#39; +
<a name="line228"></a>      &#39;(Ensure an exception was not swallowed.)&#39;, 2, loggedErrors);
<a name="line229"></a>}
<a name="line230"></a>
<a name="line231"></a>function testHandleException_includesContext() {
<a name="line232"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line233"></a>  var loggedErrors = 0;
<a name="line234"></a>  var testError = new Error(&#39;test error&#39;);
<a name="line235"></a>  var testContext = { &#39;contextParam&#39; : &#39;contextValue&#39; };
<a name="line236"></a>  goog.events.listen(errorReporter,
<a name="line237"></a>      goog.debug.ErrorReporter.ExceptionEvent.TYPE,
<a name="line238"></a>      function(event) {
<a name="line239"></a>        assertNotNullNorUndefined(event.error);
<a name="line240"></a>        assertObjectEquals({ contextParam: &#39;contextValue&#39; }, event.context);
<a name="line241"></a>        loggedErrors++;
<a name="line242"></a>      });
<a name="line243"></a>  errorReporter.handleException(testError, testContext);
<a name="line244"></a>  assertEquals(&#39;Expected 1 error. &#39; +
<a name="line245"></a>      &#39;(Ensure an exception was not swallowed.)&#39;, 1, loggedErrors);
<a name="line246"></a>}
<a name="line247"></a>
<a name="line248"></a>function testContextProvider() {
<a name="line249"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;,
<a name="line250"></a>      function(error, context) {
<a name="line251"></a>        context.providedContext = &#39;value&#39;;
<a name="line252"></a>      });
<a name="line253"></a>  var loggedErrors = 0;
<a name="line254"></a>  var testError = new Error(&#39;test error&#39;);
<a name="line255"></a>  goog.events.listen(errorReporter,
<a name="line256"></a>      goog.debug.ErrorReporter.ExceptionEvent.TYPE,
<a name="line257"></a>      function(event) {
<a name="line258"></a>        assertNotNullNorUndefined(event.error);
<a name="line259"></a>        assertObjectEquals({ providedContext: &#39;value&#39; } , event.context);
<a name="line260"></a>        loggedErrors++;
<a name="line261"></a>      });
<a name="line262"></a>  errorReporter.handleException(testError);
<a name="line263"></a>  assertEquals(&#39;Expected 1 error. &#39; +
<a name="line264"></a>      &#39;(Ensure an exception was not swallowed.)&#39;, 1, loggedErrors);
<a name="line265"></a>}
<a name="line266"></a>
<a name="line267"></a>function testContextProvider_withOtherContext() {
<a name="line268"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;,
<a name="line269"></a>      function(error, context) {
<a name="line270"></a>        context.providedContext = &#39;value&#39;;
<a name="line271"></a>      });
<a name="line272"></a>  var loggedErrors = 0;
<a name="line273"></a>  var testError = new Error(&#39;test error&#39;);
<a name="line274"></a>  goog.events.listen(errorReporter,
<a name="line275"></a>      goog.debug.ErrorReporter.ExceptionEvent.TYPE,
<a name="line276"></a>      function(event) {
<a name="line277"></a>        assertNotNullNorUndefined(event.error);
<a name="line278"></a>        assertObjectEquals(
<a name="line279"></a>            { providedContext: &#39;value&#39;, otherContext: &#39;value&#39; },
<a name="line280"></a>            event.context);
<a name="line281"></a>        loggedErrors++;
<a name="line282"></a>      });
<a name="line283"></a>  errorReporter.handleException(testError, { &#39;otherContext&#39; : &#39;value&#39; });
<a name="line284"></a>  assertEquals(&#39;Expected 1 error. &#39; +
<a name="line285"></a>      &#39;(Ensure an exception was not swallowed.)&#39;, 1, loggedErrors);
<a name="line286"></a>}
<a name="line287"></a>
<a name="line288"></a>function testHandleException_ignoresExceptionsDuringEventDispatch() {
<a name="line289"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line290"></a>  goog.events.listen(errorReporter,
<a name="line291"></a>      goog.debug.ErrorReporter.ExceptionEvent.TYPE,
<a name="line292"></a>      function(event) {
<a name="line293"></a>        fail(&#39;This exception should be swallowed.&#39;);
<a name="line294"></a>      });
<a name="line295"></a>  errorReporter.handleException(new Error());
<a name="line296"></a>}
<a name="line297"></a>
<a name="line298"></a>function testDisposal() {
<a name="line299"></a>  errorReporter = goog.debug.ErrorReporter.install(&#39;/errorreporter&#39;);
<a name="line300"></a>  if (!goog.userAgent.IE) {
<a name="line301"></a>    assertNotEquals(originalSetTimeout, window.setTimeout);
<a name="line302"></a>  }
<a name="line303"></a>  goog.dispose(errorReporter);
<a name="line304"></a>  assertEquals(originalSetTimeout, window.setTimeout);
<a name="line305"></a>}
<a name="line306"></a>
<a name="line307"></a>function testSetContextPrefix() {
<a name="line308"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line309"></a>  errorReporter.setContextPrefix(&#39;baz.&#39;);
<a name="line310"></a>  errorReporter.sendErrorReport(
<a name="line311"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line312"></a>  assertEquals(&#39;trace=trace&amp;baz.foo=bar&#39;, MockXhrIo.lastContent);
<a name="line313"></a>}
<a name="line314"></a>
<a name="line315"></a>function testTruncationLimit() {
<a name="line316"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line317"></a>  errorReporter.setTruncationLimit(6);
<a name="line318"></a>  errorReporter.sendErrorReport(
<a name="line319"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line320"></a>  assertEquals(&#39;trace=&#39;, MockXhrIo.lastContent);
<a name="line321"></a>}
<a name="line322"></a>
<a name="line323"></a>function testZeroTruncationLimit() {
<a name="line324"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line325"></a>  errorReporter.setTruncationLimit(0);
<a name="line326"></a>  errorReporter.sendErrorReport(
<a name="line327"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line328"></a>  assertEquals(&#39;&#39;, MockXhrIo.lastContent);
<a name="line329"></a>}
<a name="line330"></a>
<a name="line331"></a>function testTruncationLimitLargerThanBody() {
<a name="line332"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line333"></a>  errorReporter.setTruncationLimit(9999);
<a name="line334"></a>  errorReporter.sendErrorReport(
<a name="line335"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line336"></a>  assertEquals(&#39;trace=trace&amp;context.foo=bar&#39;, MockXhrIo.lastContent);
<a name="line337"></a>}
<a name="line338"></a>
<a name="line339"></a>function testSetNegativeTruncationLimit() {
<a name="line340"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line341"></a>  assertThrows(function() {
<a name="line342"></a>    errorReporter.setTruncationLimit(-10);
<a name="line343"></a>  });
<a name="line344"></a>}
<a name="line345"></a>
<a name="line346"></a>function testSetTruncationLimitNull() {
<a name="line347"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line348"></a>  errorReporter.setTruncationLimit(null);
<a name="line349"></a>  errorReporter.sendErrorReport(
<a name="line350"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line351"></a>  assertEquals(&#39;trace=trace&amp;context.foo=bar&#39;, MockXhrIo.lastContent);
<a name="line352"></a>}
<a name="line353"></a>
<a name="line354"></a>function testAttemptAutoProtectWithAllowAutoProtectOff() {
<a name="line355"></a>  goog.debug.ErrorReporter.ALLOW_AUTO_PROTECT = false;
<a name="line356"></a>  assertThrows(function() {
<a name="line357"></a>    errorReporter = new goog.debug.ErrorReporter(
<a name="line358"></a>        &#39;/log&#39;, function(e, context) {}, false);
<a name="line359"></a>  });
<a name="line360"></a>}
<a name="line361"></a>
<a name="line362"></a>function testSetAdditionalArgumentsArgsEmptyObject() {
<a name="line363"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line364"></a>  errorReporter.setAdditionalArguments({});
<a name="line365"></a>  errorReporter.sendErrorReport(
<a name="line366"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line367"></a>  assertEquals(&#39;/log?script=filename.js&amp;error=message&amp;line=123&#39;,
<a name="line368"></a>      MockXhrIo.lastUrl);
<a name="line369"></a>}
<a name="line370"></a>
<a name="line371"></a>function testSetAdditionalArgumentsSingleArgument() {
<a name="line372"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line373"></a>  errorReporter.setAdditionalArguments({&#39;extra&#39;: &#39;arg&#39;});
<a name="line374"></a>  errorReporter.sendErrorReport(
<a name="line375"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line376"></a>  assertEquals(&#39;/log?script=filename.js&amp;error=message&amp;line=123&amp;extra=arg&#39;,
<a name="line377"></a>      MockXhrIo.lastUrl);
<a name="line378"></a>}
<a name="line379"></a>
<a name="line380"></a>function testSetAdditionalArgumentsMultipleArguments() {
<a name="line381"></a>  errorReporter = new goog.debug.ErrorReporter(&#39;/log&#39;);
<a name="line382"></a>  errorReporter.setAdditionalArguments({&#39;extra&#39;: &#39;arg&#39;, &#39;cat&#39;: &#39;dog&#39;});
<a name="line383"></a>  errorReporter.sendErrorReport(
<a name="line384"></a>      &#39;message&#39;, &#39;filename.js&#39;, 123, &#39;trace&#39;, {&#39;foo&#39;: &#39;bar&#39;});
<a name="line385"></a>  assertEquals(
<a name="line386"></a>      &#39;/log?script=filename.js&amp;error=message&amp;line=123&amp;extra=arg&amp;cat=dog&#39;,
<a name="line387"></a>      MockXhrIo.lastUrl);
<a name="line388"></a>}
</pre>


</body>
</html>
